

//目前只兼容了webpack作为主项目的情况
let isMfcNestedInOtherProject=Object.keys(globalThis).filter(s=>s.toLowerCase().startsWith('webpack')).length>0
if(isMfcNestedInOtherProject){
  globalThis._isMfcNestedInOtherProject=true;
}
let isProdMode=false;
try{
if('development'!=process.env.NODE_ENV){
  isProdMode=true
}
}catch(e){

}
let isLocal =  globalThis?.location?.hostname == 'localhost'
// let isLocal = globalThis?.location?.hostname == '127.0.0.1' || globalThis?.location?.hostname == 'localhost'
isLocal=false;
window._IS_LOCAL_HOST=isLocal
// let staticPath = null || (isLocal ? '/mfc-src/' : 'https://staticfe.yunwoke.com/app_erpcloth/static/');//testing env
let staticPath=window._ROOT_PATH_NAME+'/mfc-src/'
// let staticPath='/mfc-src/'
// let staticPath='/mfc-src/'
// alert(window._ROOT_PATH_NAME)
let staticPathCss=window._ROOT_PATH_NAME+'/mfc-src/'
// let staticPathCss='/mfc-src/'
// let staticPathCss='/mfc-src/'
if (globalThis?.location?.hostname == 'abcdefg.com') {
  staticPath = 'https://abcdefg.com/app_erpcloth/static/'
}
// window.$v3.doNothing('staticPath---:',staticPath)
// let staticPath = '/app/erp/clothing/static/';
// let staticPath = localStorage.getItem('staticPath')||'/app/erp/clothing/static/';
// let staticServerPort = 3009;
let staticServerPort = 3009;
let locationOrigin=globalThis?.location?.origin||'http://127.0.0.1:3009'
if(isMfcNestedInOtherProject && isLocal){
  locationOrigin='http://127.0.0.1:3009'
}
if(isProdMode){
  locationOrigin=''
}
// window.$v3.doNothing('env---:',process.env.NODE_ENV)
let esmJsDir = isLocal
// let esmJsDir = (process.env.NODE_ENV == 'development' || process.env.NODE_ENV == 'dev')
  // ? ("http://127.0.0.1:" + staticServerPort + "/")
  // ? ("http://127.0.0.1:" + staticServerPort + "/src/mfc/mfc_comps/")
  ? (locationOrigin+"/mfc-src/")
  // ? ("http://127.0.0.1:3009/mfc-src/")
  : (staticPath)

  let loadScriptJsDir = isLocal
  // let esmJsDir = (process.env.NODE_ENV == 'development' || process.env.NODE_ENV == 'dev')
    // ? ("http://127.0.0.1:" + staticServerPort + "/")
    // ? ("http://127.0.0.1:" + staticServerPort + "/src/mfc/mfc_comps/")
    // ? ("http://127.0.0.1:3009/mfc-src/")
    ? (locationOrigin+"/mfc-src/")
    : './mfc-src/'
    // : '/mfc-src/'

  let dirCss = isLocal
  // let esmJsDir = (process.env.NODE_ENV == 'development' || process.env.NODE_ENV == 'dev')
    // ? ("http://127.0.0.1:" + staticServerPort + "/")
    // ? ("http://127.0.0.1:" + staticServerPort + "/src/mfc/mfc_comps/")
    // ? ("http://127.0.0.1:3009/mfc-src/")
    ? (locationOrigin+"/mfc-src/")
    : (staticPathCss)

// sessionStorage.setItem('PROD_DEBUG',1);
// location.reload();
let isProdDebug = globalThis?.localStorage?.getItem('PROD_DEBUG') || globalThis?.sessionesmJsDirStorage?.getItem('PROD_DEBUG')
let useBigAntD = globalThis?.localStorage?.getItem('BIG_ANTD') || globalThis?.sessionStorage?.getItem('BIG_ANTD')
let hour = new Date().getHours();
let miniute = new Date().getMinutes();
if (hour == 22 && miniute >= 30 || globalThis?.location?.hostname == 'localhost') {
  useBigAntD = true;
}


useBigAntD=false;//////////////////////////////////////////////////////////////////////////////////////////////////
if (isProdDebug) {
  esmJsDir = ("http://127.0.0.1:" + staticServerPort + "/")
  // staticPath='/static/'
  globalThis?.eval(`console.log('will use prod debug mode,base url is: ${esmJsDir}')`)
  // console.log('will use prod debug mode,base url is: '+esmJsDir)
}

// setTimeout(() => {
//   delete globalThis.mfcBizConfig
// })




globalThis.mfcBizConfig = {
  dealyTimeOfDialogShowWhenLoad: isProdDebug || isLocal ? 0 : 20000,
  getRouterBasePath() {
    let baseP = '/app/erp/clothing/'
    if (location.pathname.startsWith(baseP)) {
      return baseP;
    } else {
      return '/'
    }
  },
  isProductionDebugMode() {

    if (localStorage.getItem('production_debug')) {
      return true;
    }
    return false;
  },
  pushStateHandlerDebounceDuration() {
    let d = localStorage.getItem('pushstate_debounce_duration')
    let res;
    if (d) {
      let time = d - 0;
      if (Number.isInteger(time)) {
        res = time;
      }
      else {
        res = 20;
      }
    }
    return res;
  },
  routerPageContainerSelector: '.ant-layout .ant-layout',
  setRouterPageContainerHeight(isDevServer) {

    return document.documentElement.clientHeight - (isDevServer ? 0 : 50);

    // height: calc(668px - 50px);
    // overflow-y: scroll;

  },
  forceUpdateSidebarMenuClassTrigger: ['li.ant-menu-submenu'],
  forceUpdateSidebarMenuClass() {
    let activedMenuItemClassName = 'ant-menu-item-selected'
    let previousMenuItem = document.querySelector('.' + activedMenuItemClassName)
    if (previousMenuItem) {
      previousMenuItem.classList.remove(activedMenuItemClassName)
    }

    setTimeout(() => {
      let arr = Array.from(document.querySelectorAll('.ant-menu li'));
      // window.$v3.doNothing(arr.map(s=>s.dataset))
      let routerBasePath = window.$v3.bizConfig.getRouterBasePath()
      let p = location.pathname.split(routerBasePath).slice(1).join(routerBasePath)
      window.$v3.doNothing('p---:', p)
      // console.log('arr--:',arr.length,arr)
      let newTarget = arr.find((obj) => {
        // console.log('dataset--:',obj.dataset)
        let pp = (obj?.dataset?.menuId || '').split('-/').reverse()[0]
        // console.log('pp---:',pp)
        let res = pp && (p.endsWith(pp))

        return res;

      })
      // let newTarget=arr.find((obj)=>((obj?.dataset?.menuId||'').endsWith(p)))
      // window.$v3.doNothing('newTarget---:',newTarget)
      if (newTarget) {
        newTarget.classList.add(activedMenuItemClassName)
      }

    })

  },
  shouldPageAutoLoadWhenHistoryChange(url) {

    url = url || location.pathname;
    // console.log('url---:',url)
    let res;
    if (url.split('/').length > 1) {
      res = url.split('/').reverse()[1] == 'charts'
    } else {
      res = location.pathname.split('/').reverse()[0] == url
    }


    if (!window.$v3.$utils.isDevServer()) {
      if (!res) {
        document.body.style.overflowY = 'scroll'
      } else {
        document.body.style.overflowY = 'initial'
      }
    }

    return res;



    //   alert(url)
    //  return url.split('/').reverse()[1]=='charts' || location.pathname.split('/').reverse()[0]==url
    //  let res=location.pathname.split('/').reverse()[1]=='charts' && location.pathname.endsWith(url)
    //  alert(res)
    // return location.pathname.split('/').reverse()[1]=='charts';
    // return res || url=='mfc-app'
    // return res || url=='mfc-app'
    // return url.startsWith('/charts/')
  },
  // localeProvider: require('/scada/mfc_modules/antd/antd.zh-cn.json'),
  // tableHeaderInfos:require('./erp_v4/table-header-info.js'),
  localeProviderTag: 'a-config-provider',
  appTemplatePreSloter(compPath, workspaceDir, isAppEntryComp) {
    // console.log('compPath,workspaceDir--:', compPath, workspaceDir)
    if (isAppEntryComp) {
      return ''
    }
    if ('mfc-components-for-react-jsx'.split(' ').includes(workspaceDir)) {
      return ''
    }

    let componentName = (location.href.split('?')[0].split('/').reverse()[0])
    let title = {
      'factory': '工厂报表',
      'customer': '客户报表',
      'profit': '毛利报表',
      'goods': '商品报表',
      'delivery': "出货报表",
      'price': '价格报表',
      'orders': '订单报表',
      'order_sales': '订单报表-销售',
      'order_purchase': '订单报表-采购',
    }[componentName]

    if (!title) {
      return ''
    }
    // window.$v3.doNothing('htmlllllllllllll_--:',html)
    // return ''
    return `
    <div class="ant-page-header ant-page-header-ghost">
      <div class="ant-page-header-heading">
        <div class="ant-page-header-heading-left"><span class="ant-page-header-heading-title" title="${title}">${title}</span></div>
        
      </div>
    </div>`
  },
  staticServerPort: staticServerPort,
  // mfcCompsFolderOfStaticServer: '/src/mfc/mfc_comps',//for express dev server
  primaryWorkspaceDir: '',
  // primaryWorkspaceDir: 'pages',
  UI_LIB_DEFINER($) {
    if (window.antd) {
      // window.$v3.doNothing('window.antd---:',window.antd,$)
      $.use(window.antd.default)
    }
    window.$v3.$APP$=$;
    if(window.vuedraggable){
      
      $.component(window.vuedraggable.name,window.vuedraggable)
      // $.use(window.vuedraggable)
    }

    // if (window.dayjs) {
    //   dayjs.locale('zh-cn');
    // }



    // if(window._CLI_ElementPlus){
    //   $.use(window._CLI_ElementPlus)
    // }

    if (window.ElementPlus) {
      $.use(window.ElementPlus,{
        locale:ELEMENT_LOCLE_ZH_CN
      });
    }


    if (window.ElementPlusIconsMFC) {
      for (let i in window.ElementPlusIconsMFC) {
        $.component(
          window.ElementPlusIconsMFC[i].name,
          window.ElementPlusIconsMFC[i]
        );
      }

      $.config.globalProperties.ElementPlusIconsMFC = ElementPlusIconsMFC;
    }




  },
  mfcLibPath:esmJsDir + 'mfc_modules/mfc-deps-with-element-all.js',
  // mfcLibPath: esmJsDir + 'mfc_modules/mfc.global.uglify.js',
  // mfcLibPath: esmJsDir + 'mfc_modules/mfc.global.js',
  mfcRouterLibPath: null,
  // mfcRouterLibPath: esmJsDir + 'mfc_modules/mfc.router.uglify.js',
  // mfcRouterLibPath: esmJsDir + 'mfc_modules/mfc.router.js',
  // mfcRouteConfig: function(){
  //   return [
      // { path: '/', redirect:'/money' },
      // { path: '/money', component:  {...globalThis.mfcRouterAdapter},meta:{ mfcPath:'money/money'} },
  //     { path: '/twoWords', component: {... globalThis.mfcRouterAdapter},meta:{ mfcPath:'two-worlds/two-worlds'} },
  //     { path: '/monthPay', component: {... globalThis.mfcRouterAdapter},meta:{ mfcPath:'month-pay/month-pay'} },
  //     { path: '/unityVip', component: {... globalThis.mfcRouterAdapter},meta:{ mfcPath:'unity-vip/unity-vip'} },
  //     { path: '/404', component: {template:'<div>404</div>'} },
  //     {path: '/:pathMatch(.*)',redirect:'/404'}
  //     // { path: '/about', component: About },
  // ];

  // },
  mfcRouteConfig: esmJsDir + 'mfc.route.config.js?r='+Math.random(),
  // mfcRouteMode:isProdMode?'hash':'history',
  mfcRouteMode:'hash',
  // mfcRouteMode:'history',
  useMfcRouter:true,
  loadJsAndCssAtSameTime:true,
  // globalComponentsLoaderName: null,//这个不需要dir前缀,bootstrap里会加上
  globalComponentsLoaderName: 'mfc-global-components-loader.m.htm',//这个不需要dir前缀,bootstrap里会加上
  esmJsDir: esmJsDir,
  loadScriptJsDir: loadScriptJsDir,

  CSS_DEPS: [
    dirCss + 'mfc_modules/vuedraggable/bootstrap4.5.3/bootstrap.css',
    // dirCss + 'mfc_modules/vuedraggable/demo.css',

    dirCss + 'mfc_modules/element-plus/element-styles/element.style.css',

    // '//unpkg.com/element-plus/dist/index.css',
    // dirCss + 'mfc_modules/antd/antd.css',

    // dirCss + 'mfc-global.css',
  ],
  JS_DEPS: [
    [
      // esmJsDir+'mfc_modules/vuedraggable/Sortable.min.js'
      // esmJsDir + 'mfc_modules/dayjs.js'//element中内置了dayjs
      // , 
      esmJsDir + 'mfc_modules/xhook.js'
    ],
    [
      esmJsDir+'mfc_modules/vuedraggable/vuedraggable.umd.min.js'//需要事先在index.html中引入sortable.js
      
    ],
    // [
    //   (function () {
    //     return () => {

    //       let theResolver = null;
    //       window.$v3.$utils.sequenceExecPromiseArr.__PENDING = new Promise(function (resolve) {
    //         theResolver = resolve;
    //         // console.log('this this--:',this)
    //         setTimeout(() => {
    //           window.$v3.$utils.sequenceExecPromiseArr.__PENDING.then(() => {
    //             delete window.$v3.$utils.sequenceExecPromiseArr.__PENDING;
    //           })
    //         })

    //       })
    //       setTimeout(async () => {
    //         try {
    //           // await window.__IMPORT(esmJsDir + 'save-btn-debounce.js?r=' + Math.random());
    //         } catch (e) {
    //           throw e;

    //         } finally {
    //           setTimeout(() => {
    //             theResolver();

    //           })
    //           // },5000)
    //         }

    //       })

    //     }
    //   })(),
    //   // (function () {
    //   //   // let pendingPostUrlMap = {}
    //   //   // let lastShouldDisabledButtons;
    //   //   // let apiRequestCount=0;
    //   //   return () => {
    //   //     let theResolver=null;
    //   //     window.$v3.$utils.sequenceExecPromiseArr.__PENDING=new Promise(function(resolve){
    //   //       theResolver=resolve;
    //   //       // console.log('this this--:',this)
    //   //       setTimeout(()=>{
    //   //         window.$v3.$utils.sequenceExecPromiseArr.__PENDING.then(()=>{
    //   //           delete window.$v3.$utils.sequenceExecPromiseArr.__PENDING;
    //   //         })
    //   //       })

    //   //     })
    //   //     setTimeout(async ()=>{
    //   //       // localStorage.setItem('debug_patch','http://localhost:3002/debug-patch.js')
    //   //       // sessionStorage.setItem('debug_patch','http://localhost:3002/debug-patch.js')

    //   //       // localStorage.removeItem('debug_patch')
    //   //       // sessionStorage.removeItem('debug_patch')

    //   //       let debugPatchFilePath=localStorage.getItem('debug_patch')||sessionStorage.getItem('debug_patch')||''
    //   //       debugPatchFilePath=debugPatchFilePath.trim()+'?_rand='+Math.random();
    //   //       try{
    //   //         let shouldLoadDebug=debugPatchFilePath.startsWith('http://') || debugPatchFilePath.startsWith('https://')

    //   //         // alert(shouldLoadDebug)
    //   //         if(shouldLoadDebug){
    //   //           console.log('debugPatchFilePath will be load---:',debugPatchFilePath)
    //   //           await window.__IMPORT(debugPatchFilePath);
    //   //           // theResolver();
    //   //         }
    //   //         // else{
    //   //         //   theResolver();
    //   //         // }
    //   //       }catch(e){
    //   //         throw e;

    //   //       }finally{
    //   //         setTimeout(()=>{
    //   //           theResolver();

    //   //         })
    //   //         // },5000)
    //   //       }

    //   //     })
    //   //     return new Promise((resolve)=>{



    //   //       // ;(function (open) {
    //   //       //   XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
    //   //       //     console.log('url----------:',url)
    //   //       //     // alert(method.toUpperCase()=='POST')
    //   //       //     // if(false){
    //   //       //     if(method.toUpperCase()=='POST'){
    //   //       //       if(pendingPostUrlMap[url]){
    //   //       //         setTimeout(()=>{
    //   //       //           console.log('this---:',this)
    //   //       //           this.abort()
    //   //       //         })
    //   //       //         // this.send=()=>{}
    //   //       //       }else{
    //   //       //         pendingPostUrlMap[url]=true;
    //   //       //         this.addEventListener("readystatechange", function () {
    //   //       //           if(this.readyState==4){
    //   //       //             delete pendingPostUrlMap[url]
    //   //       //           }


    //   //       //         }, false);

    //   //       //       }





    //   //       //     }
    //   //       //     // else{
    //   //       //     //   return open.call(this, method, url, async, user, pass);
    //   //       //     // }
    //   //       //     open.call(this, method, url, async, user, pass);

    //   //       //   };
    //   //       // })(XMLHttpRequest.prototype.open);


    //   //       // ;(function (open) {
    //   //       //   XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
    //   //       //     XPathResult.abort()
    //   //       //     this.addEventListener("readystatechange", function () {
    //   //       //       console.log('readystate: ' + this.readyState);


    //   //       //     }, false);


    //   //       //     open.call(this, method, url, async, user, pass);
    //   //       //   };
    //   //       // })(XMLHttpRequest.prototype.open);

            // xhook.before(function (request, cb) {

            //   if (request.method.toUpperCase() == 'POST') {
            //     // console.log('request ---:', request, cb)
            //     let url = request.url;
            //     if (!pendingPostUrlMap[url]) {
            //       cb()
            //     }
            //     pendingPostUrlMap[url] = true;
            //   } else {
            //     cb()
            //   }
            //   // cb()
            // });








    //   //       // xhook.after(function(request, response,cb) {
    //   //       //   // console.log('xhook after--:',request,response,cb)
    //   //       //   // cb()
    //   //       //  });

    //   //       resolve()


    //   //     })


    //   //   }
    //   // })(),
    // ],
    // [esmJsDir + 'mfc_modules/dayjs.zh_cn.js'],
    [esmJsDir+'mfc_modules/element-plus/locale/zh-cn.js',],
    [esmJsDir+'mfc_modules/echarts/echarts.min.js'],
    [
    //   esmJsDir+'mfc_modules/element-plus/element.uglify.js?v=1',
    //  esmJsDir+'mfc_modules/element-plus/element.min.js?v=1',
    //   // esmJsDir + 'mfc_modules/antd/antd' + (useBigAntD ? '.big' : '') + '.js'
    ],
    [esmJsDir + 'mfc_modules/element-plus/icon.js?v=1']
    // [esmJsDir + 'mfc_modules/mfc-deps-with-element-all.js']
  ],
  loadMfcDepsWhenDocumentReady: true,
  targetAndIdWhenHmr(nextUrl, workspaceDir) {
    window.$v3.doNothing('nextUrl,workspaceDir--:', nextUrl, workspaceDir)
    if (nextUrl === 'mfc-app') {
      return {
        target: 'body',
        id: 'mfc-app'
      }
    }
  },
  useMfcEntryComponent: true,
  // useMfcEntryComponent:false,
  watiUntil() {
    return true;
    // return Array.isArray(window.MENUS)
  },
  globalProperties: {
    gShouldShowTooltip({ title }, key) {
      if (!((window.$v3.bizConfig.tableHeaderInfos[key] || {})[title])) {
        return false;
      }
      return (
        title.endsWith('金额')
        || title.endsWith('额')
        || title.endsWith('量')
        || title.endsWith('利')
        || title.endsWith('数')
        || title.endsWith('率')
        || title.endsWith('价')
        || title.endsWith('本')
      )
    },
    // window.$v3.bizConfig.globalProperties.shouldAlertNotifyDialog();
    shouldAlertNotifyDialog() {
      return true;

      // if(window.shouldAlertNotifyDialog){
      //   return window.shouldAlertNotifyDialog;
      // }

      // if(!sessionStorage.getItem('_FIRST_LOADED_PAGE')){
      //   sessionStorage.setItem('_FIRST_LOADED_PAGE',1);
      //   window.shouldAlertNotifyDialog=true;
      //   return true;
      // }else{
      //   return false;
      // }
      // let hasNumber=Boolean(location.pathname.split('?')[0].split('/').filter(s=>s).find(s=>Number.isInteger(s-0)));
      // let isCraft=Boolean(location.pathname.split('?')[0].split('/').find(s=>s=='craft'));
      // let 
    },

    setBodyOverflowScroll() {
      // if(true){
      if (!window.$v3.$utils.isDevServer()) {
        // console.log('body will be set overflow scroll')


        if (!window.$v3.bizConfig.shouldPageAutoLoadWhenHistoryChange()) {
          setTimeout(() => {
            document.body.style.overflowY = 'scroll'
          }, 100)
        } else {
          document.body.style.overflowY = 'initial'
        }
      } else {
        document.body.style.overflowY = 'initial'
      }

    },
    generateUrlByQueryObject(obj) {
      let previousObj = obj;
      // obj={
      //   ...obj
      // }
      let newObj = {};
      for (let i in obj) {
        if (!(i.startsWith('_') && i.endsWith('__'))) {
          newObj[i] = obj[i]
        }
      }
      // console.log('previous obj and obj--:', previousObj, newObj)


      if (newObj.group_by == 'month') {
        newObj.start_at = previousObj._yearModel__.model + '-01-01';
        newObj.end_at = previousObj._yearModel__.model + '-12-31';
      }

      let str = '&';
      for (let i in newObj) {
        if (i != 'page' && i != 'size') {
          str += i + '=' + newObj[i] + '&'
        }
      }




      return str;
    },
    hasPermission(key) {
      return window.MENUS.find((s => s.menu_address == key)) ? true : false
    }
  },
  transformRequestPayLoad(urlKey, bodyKey, b) {
    // console.log('urk key in trans---:',urlKey,bodyKey,b)
    if (bodyKey == 'queryData') {
      if ('getDeliveryChartCharts getProfitChartList getProfitChartCharts getOrderSalesChartCharts '.split(" ").includes(urlKey)) {
        if (b.group_by == 'month') {
          // debugger;
          b.start_at = b._yearModel__.model + '-01-01'
          b.end_at = b._yearModel__.model + '-12-31'
        }
      }
    }

    return b;
  },
  transformMfcFileContent(str, path) {
    // console.log('path in trans mfc file--:',path)
    if (('erp_v4/delivery erp_v4/profit erp_v4/order_purchase erp_v4/order_sales').split(' ').find(s => path.endsWith(s))) {
      str = str.replace('<a-range-picker ', `
      <span v-init="{

        mounted:()=>{queryParams._yearModel__={model:false} }
      }">
      
      <a-date-picker
      :defaultValue="win.dayjs((queryParams._yearModel__.model||'${(new Date().getFullYear())}')  +'-01-01')"
      v-init="{mounted:()=>{ 
        if(!('__shouldWatchYearModel__' in queryParams)){
          queryParams.__shouldWatchYearModel__=true;


          win.MFC.watch(()=>queryParams.group_by,()=>{
            ifLoadPagination=false;
            doQuery()
            win.setTimeout(()=>{
            
              ifLoadPagination=true;
            })
            
          },{
            deep:true
          });
          win.MFC.watch(queryParams._yearModel__,()=>{
            if(!queryParams.__shouldWatchYearModel__){
              return false;
            }
            ifLoadPagination=false;
            doQuery()
            win.setTimeout(()=>{
            
              ifLoadPagination=true;
            })
            queryParams.__shouldWatchYearModel__=false;
          })
          
          queryParams._yearModel__.model=new win.Date().getFullYear()
        }
        
        
          }}"
        @change="(p1,p2)=>(queryParams._yearModel__.model=(''+p2))" 
      v-if="queryParams.group_by=='month'" picker="year" />
      
      </span>
      `+ `<a-range-picker v-if="queryParams.group_by=='day'" `)
    }
    return str;
  },
  notifyDialogWhenAppReadyInDevMode: isLocal ? false : true,
  async onReady() {
    // return true;
    let div = document.createElement('div');
    document.body.prepend(div);
    div.id = 'mfc-app'
    window.$v3.doNothing('objjjjjjjj--------:', document.querySelector('#' + div.id))
    // await Promise.resolve();

    function promisePoll(fn){
      return new Promise((resolve)=>{
        let loop=()=>{
          if(fn()){
            resolve()
          }else{
            setTimeout(()=>{
                loop()
            },16)
          }
        }
        loop()
      })
    }
    await promisePoll(()=>typeof(window?.$v3?.$mountMfcComponent)!='undefined')

    // setTimeout(async () => {
      
      await window.$v3.$mountMfcComponent('#' + div.id, 'mfc-app', window.$v3.bizConfig.providedVariablesForMfc, '', true)
      
      window.$v3.isAppEntryCompLoaded=true;

      try{
        if(window.HACKER.$bus.emit){
          window.HACKER.$bus.emit('MFC_READY')
        }
      }catch(e){}
      
    // }, 1000 * (window.$v3.$utils.isDevServer() ? 1 : 1))
    // }, 1000 * (window.$v3.$utils.isDevServer() ? 1 : 30))

    // await window.$v3.$mountMfcComponent('#' + div.id, 'mfc-app', window.$v3.bizConfig.providedVariablesForMfc, '', true)
    // alert('after')
    // mfcAppBootstrap();
  }

}